package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-08-17
 * Time: 10:51
 */
public class FindOperation implements IOperation{
    public void work(BookList bookList) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要查找图书的名字");
        String name=sc.nextLine();

        //遍历书架，去查找有无此书
        int currentSize=bookList.getUsedSized();
        for (int i = 0; i <currentSize; i++)
            if (name.equals(bookList.getBooks(i).getName())) {
                System.out.println("查到了，该书的信息如下");
                System.out.println(bookList.getBooks(i));
                return;
            }
        System.out.println("找不到该书");
    }
}
